package fileloaders.filters;

import java.util.HashSet;

import fileloaders.fieldpositions.AOLQueryPairsFields;

public class AOLQueryPairFilter  implements TextLineFilter,AOLQueryPairsFields{

	
	HashSet<String> valid_ages=null;
	boolean onlyClicks= false;
	int clickDuration= 0;
	public AOLQueryPairFilter(HashSet<String> valid_ages, boolean onlyClicks, int clickDuration ){

		this.valid_ages=valid_ages;
		this.onlyClicks=onlyClicks;
		this.clickDuration=clickDuration;
	}
	
	
	
	@Override
	public boolean filterLine(String[] t) {
		// TODO Auto-generated method stub
	
		 String age = t[this._eval_bucket];
	//	 String query = t[this._eval_query];
	//	 String refor = t[this._eval_query_reformulation];
		
		 String hasClick = t[this._eval_flagClick];
		 
		 int duration = Integer.valueOf(t[this._eval_time]);
		 
		 if(duration<clickDuration)
			 return false;
		 
		 if(onlyClicks && !hasClick.toLowerCase().equals("true"))
			 return false;
		 
		 if(!valid_ages.contains(age))
			 return false;
		
		 
		 
		return false;
	}

}
